package com.yuyou.train.user.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yuyou.train.service.api.user.entity.UserDynamic;
import com.yuyou.train.user.mapper.UserDynamicMapper;
import com.yuyou.train.user.service.IUserDynamicService;
import com.yuyou.train.user.service.IUserPraiseService;
import com.yuyou.train.user.vo.resp.RespUserDynamic;
import com.yuyou.train.util.bean.Pagination;
import com.yuyou.train.util.bean.ResBoolSimpleInfo;
import com.yuyou.train.util.tool.Sequence;
import com.yuyou.train.util.tool.UUIDUtil;

/**
 * Created by yujin.liu on 2018/3/14.
 */
@Service
public class UserDynamicServiceImpl implements IUserDynamicService{

    @Autowired
    private UserDynamicMapper userDynamicMapper;

    @Autowired
    private IUserPraiseService userPraiseService;

    @Override
    public int insert(UserDynamic userDynamic) {
    	userDynamic.setId(Sequence.getSequence().getNextId());
    	userDynamic.setCreateTime(new Date());
        return userDynamicMapper.insert(userDynamic);
    }

    @Override
    public int findUserDynamicPageCount(Pagination<RespUserDynamic> p) {
        return userDynamicMapper.findUserDynamicPageCount(p);
    }

    @Override
    public List<RespUserDynamic> findUserDynamicPage(Pagination<RespUserDynamic> p){
        return userDynamicMapper.findUserDynamicPage(p);
    }

	@Override
	public ResBoolSimpleInfo<String> addUserDynamic(UserDynamic userDynamic) {
		this.insert(userDynamic);
		return ResBoolSimpleInfo.getSuccessInfo();
	}
}
